package br.com.seuimovelnamao.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import br.com.seuimovelnamao.model.Bairro;
import br.com.seuimovelnamao.model.Cidade;
import br.com.seuimovelnamao.model.ContratacaoPlano;
import br.com.seuimovelnamao.model.Endereco;
import br.com.seuimovelnamao.model.Estado;
import br.com.seuimovelnamao.model.Imovel;
import br.com.seuimovelnamao.model.Plano;
import br.com.seuimovelnamao.model.Usuario;

public class HibernateUtil {

	private static SessionFactory factory;

	static {
		AnnotationConfiguration cfg = new AnnotationConfiguration();
		cfg.addAnnotatedClass(Imovel.class);
		cfg.addAnnotatedClass(Usuario.class);
		cfg.addAnnotatedClass(Plano.class);
		cfg.addAnnotatedClass(ContratacaoPlano.class);
		cfg.addAnnotatedClass(Estado.class);
		cfg.addAnnotatedClass(Cidade.class);
		cfg.addAnnotatedClass(Bairro.class);
		cfg.addAnnotatedClass(Endereco.class);
		
		factory = cfg.buildSessionFactory();
	}
	
	public Session getSession(){
		return factory.openSession();
	}
	
}
